Learning Objectives

After completing this lesson, you’ll be able to:

Adjacent Feature Attributes

Normally a feature in FME is self-contained. It might get processed as a group at some point, but other than that it doesn’t have any relationship to other features in the workspace.

However, in some cases, the ability for a feature to access the attributes of other features is quite useful.

For example, take a tabular dataset of coordinates recorded as follows:

X Y
+0.0 +3.0
+3.2 +0.0
-3.2 +0.0
+0.0 +3.4
+4.2 +0.0

In this case, each row is not an absolute coordinate; instead, it is an offset from the previous one. Therefore, to calculate the true coordinates, each feature needs to know the coordinates of the previous feature, so that it can apply the offset.

You can use adjacent feature attributes in FME to calculate the true coordinates with a dataset like this.

Note

For a more complex example using the Text File reader, check out this blog post.

Adjacent Feature Functionality

Adjacent feature functionality is activated by checking the box labeled Enable Adjacent Feature Attributes in an AttributeCreator or AttributeManager transformer:

Enabling Adjacent Feature Attributes

This opens up a section of dialog in which the author can specify how many features preceding the current feature, or how many features that succeed it, should be made available. In the above screenshot attributes from the previous feature will become available.

Using Multiple Feature Attributes

The simplest way to make use of the attributes retrieved from prior/subsequent features is through the Text or Arithmetic Editors, where the list of feature attributes has an expandable section for prior and subsequent features:

Finding adjacent feature attributes in the Arithmetic Editor

Attributes become available not only for the current feature but also for previous/subsequent features that have been exposed. As with the current attribute, double-clicking an adjacent attribute adds it to the expression window:

Constructing an attribute value

In the above screenshot, the workspace author is finding the time difference between two adjacent records in a business license dataset.

You can see that prior attribute values can be accessed simply by using feature[-x] where x is a positive or negative number that refers to a subsequent or prior feature.

Note

Be aware that extra system resources are used for the storage of adjacent features. Therefore translation performance will take a (fairly minor) hit when using these capabilities, the degree of which depends on the number of features and the number of attributes being retained.

Missing Values

The AttributeCreator and AttributeManager also have an option to specify what should happen if the attributes have missing, null, or empty values:

Setting Substitute Missing, Null and Empty by parameter

When the transformer tries to use a value that is missing, null, or empty, this option lets the user choose a replacement value, or carry out no substitution.

Notice that this setting applies to attributes of the current feature, just as much as attributes of adjacent features.

Note

You can read more details about this substitution in the documentation.